package com.zd.kids.ui.view;

import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import android.view.View;

import com.blankj.utilcode.util.SPUtils;
import com.hyy.libray.common.Constant;
import com.zd.kids.R;
import com.zd.kids.ui.activity.CalendarActivity;
import com.zd.kids.ui.activity.HelpActivity;
import com.zd.kids.ui.activity.ScanActivity;
import com.zd.kids.ui.activity.UseGuideActivity;

/**
 * @ClassName: com.zd.kids.ui.view
 * @Description:
 * @Author: hyy
 * @Date: 2020/6/15
 * @Time: 6:44 PM
 */
public class CommmonBottomHelper implements View.OnClickListener {

    View viewBottom;
    View ll_scan;
    View ll_timetab;
    View ll_que;
    View ll_video;
    Context context;
    String groupId;
    String groupPosition;

    public CommmonBottomHelper(Context context, View viewBottom) {
        this.context = context;
        this.viewBottom = viewBottom;
        String groupValue = SPUtils.getInstance(Constant.GAPSK_AI_QM).getString("GROUP_ID");
        if (!TextUtils.isEmpty(groupValue) && groupValue.split(",").length == 2) {
            groupId = groupValue.split(",")[0];
            groupPosition = groupValue.split(",")[1];
        }


        ll_video = viewBottom.findViewById(R.id.ll_video);
        ll_video.setOnClickListener(this);
        ll_scan = viewBottom.findViewById(R.id.ll_scan);
        ll_scan.setOnClickListener(this);
        ll_timetab = viewBottom.findViewById(R.id.ll_timetab);
        ll_timetab.setOnClickListener(this);
        ll_que = viewBottom.findViewById(R.id.ll_que);
        ll_que.setOnClickListener(this);
        
        if (TextUtils.isEmpty(groupId) || TextUtils.isEmpty(groupId)) {
            ll_video.setVisibility(View.GONE);
        }
    }

    @Override
    public void onClick(View view) {
        int id = view.getId();
        if (id == R.id.ll_scan) {
            Intent intent = new Intent(context, ScanActivity.class);
            context.startActivity(intent);
        } else if (id == R.id.ll_timetab) {
            Intent intent = new Intent(context, CalendarActivity.class);
            context.startActivity(intent);
        } else if (id == R.id.ll_que) {
            Intent intent = new Intent(context, HelpActivity.class);
            context.startActivity(intent);
        } else if (id == R.id.ll_video) {
            Intent intent = new Intent(context, UseGuideActivity.class);
            intent.putExtra("groupPosition", groupPosition);
            intent.putExtra("groupId", groupId);
            context.startActivity(intent);
        }
    }
}
